<template>
  <div class="comment-list">
    <div class="page-title" v-if='comments.length'>
      评论
    </div>
    <div class="comment"
      v-for="comment in comments"
      :key="comment.id"
      @click="handleClick(comment)"
      >
      <div class="user">
        <div class="inline">
          <img :src="comment.image"
            class="avatar"
            mode='aspectFit'
            alt=""> {{comment.title}}
        </div>
        <div class="right">
          {{comment.location||'位置地点'}}
          <span class="text-parimary">
            --
          </span>
          {{comment.phone||'手机型号'}}
        </div>
      </div>
      <div class="content">
        {{comment.comment}}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ['comments', 'type'],
  methods: {
    handleClick(comment) {
      if(this.type === 'user'){
        wx.navigateTo({
          url: '/pages/detail/main?id=' + comment.bookid
        })
      }
    }
  }
}
</script>

<style lang='scss'>
.comment-list {
  background: #eee;
  font-size: 14px;
  .comment {
    background: #fff;
    margin-bottom: 10px;
    padding: 5px 10px;
    .content {
      margin: 10px 0;
    }
    .user {
      display: flex;
      justify-content: space-between;
      .inline {
        display: inline;
        .avatar {
          height: 20px;
          width: 20px;
          border-radius: 50%;
          vertical-align: middle;
        }
      }
    }
  }
}
</style>
